package com.ymatou.iapi.im.testcase;

import com.ymatou.iapi.im.parameter.CancelSetMessageSessionImportantBean;
import com.ymatou.iapi.im.parameter.SendMessageToBuyerBean;
import com.ymatou.iapi.im.service.CancelSetMessageSessionImportantCall;
import com.ymatou.iapi.userregister.parameter.UserRegisterInfoRequestDtoBean;
import com.ymatou.iapi.userregister.service.UserRegisterInfoRequestDtoCall;
import com.ymttest.business.service.ImCallService;
import com.ymttest.business.service.JUserCallService;
import com.ymttest.database.sqlwapper.ImDefaultWapper;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;

import java.util.Map;

/**
*客服取消标记重要会话
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_CancelSetMessageSessionImportant{
	private static CancelSetMessageSessionImportantBean cancelsetmessagesessionimportantBean;
	private static CancelSetMessageSessionImportantCall cancelsetmessagesessionimportantCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("客服取消标记重要会话");
	}

	@Before
	public void caseUp() {
		cancelsetmessagesessionimportantBean=new CancelSetMessageSessionImportantBean();
		cancelsetmessagesessionimportantCall=new CancelSetMessageSessionImportantCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(cancelsetmessagesessionimportantCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CancelSetMessageSessionImportant_01() {
		Logger.start(true,"客服取消标记重要会话");
		try {
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);
			Integer userId = urrc.getUserid();
			int fromUserId = 24635724;
			SendMessageToBuyerBean sendMessageToBuyerBean = ImCallService.initSendMessageToBuyerBean(fromUserId,userId,"nihao");
			ImCallService.SendMessageToBuyer(sendMessageToBuyerBean);
			ImCallService.SetMessageSessionImportant(fromUserId,userId);
			ImDefaultWapper im = new ImDefaultWapper();
			Map map = im.selectTotalCount(userId,fromUserId).get(0);
			Logger.verifyEquals(1,map.get("IsImportant"),"验证是否标记为重要会话");

			cancelsetmessagesessionimportantBean.setUserId(fromUserId);
			cancelsetmessagesessionimportantBean.setToUserId(userId);
			cancelsetmessagesessionimportantCall.setData(cancelsetmessagesessionimportantBean);
			cancelsetmessagesessionimportantCall.callService();			
			Map map1 = im.selectTotalCount(userId,fromUserId).get(0);
			Logger.debug(map1);
			Logger.verifyEquals(0,map1.get("IsImportant"),"验证是否已经取消了重要会话");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}